{% from "common/_macros.html" import static %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
{#多处需要使用到此文件，比如邮件等信息的更新，所以放置base文件中，csrf与ajax的配合使用#}
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>{% block title %}{% endblock %}</title>
    {#jQuery框架，必须放在bootstrap前面#}
    <script src="http://cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
    <link href="http://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <script src="http://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="{{ static('back/css/base.css') }}">
    <script src="{{ static('back/js/base.js') }}"></script>
{#导入封装好的flask与ajax交互的文件#}
     <script src="{{ static("common/lhajax.js") }}"></script>
{#link对应css文件，script对应js文件，加载弹跳框的提示信息相关的静态文件#}
    <link rel="stylesheet" href="{{ static('common/sweetalert/sweetalert.css') }}">
    <script src="{{ static('common/sweetalert/lhalert.js') }}"></script>
    <script src="{{ static('common/sweetalert/sweetalert.min.js') }}"></script>
{#     block head的作用是加载页面特有的额外的css或js文件#}
    {% block head %}{% endblock %}
</head>
<body>
     <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
      <div class="container-fluid">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">神毓逍遥后台管理</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav navbar-right">
{#             前端视图中通过绑定，获取g.back_user信息，此处取的username的信息#}
{#            <li><a href="#">{{ g.back_user.username }}<span>[超级管理员]</span></a></li>#}
            <li><a href="url_for{{ 'back.profile' }}">{{ g.back_user.username }}</a></li>
{#             跳转，执行back视图下的logout函数#}
             <li><a href="{{ url_for('back.logout') }}">注销</a></li>
          </ul>
          <form class="navbar-form navbar-right">
            <input type="text" class="form-control" placeholder="查找...">
          </form>
        </div>
      </div>
    </nav>
    <div class="container-fluid">
      <div class="row">
          <div class="col-sm-3 col-md-2 sidebar">
              <ul class="nav-sidebar">
                <li class="unfold"><a href="{{ url_for('back.index') }}">首页</a></li>
                <li class="profile-li">
                    <a href="#">个人中心<span></span></a>
                    <ul class="subnav">
                        <li><a href="{{ url_for('back.profile') }}">个人信息</a></li>
                        <li><a href="{{ url_for('back.resetpwd') }}">修改密码</a></li>
                        <li><a href="{{ url_for('back.resetmail') }}">修改邮箱</a></li>
                    </ul>
                </li>
                  {% set back_user = g.back_user %}
                  {% if back_user.has_permissions(BACKPermission.POSTER) %}
                      <li class="nav-group post-manage"><a href="{{ url_for('back.posts') }}">帖子管理</a></li>
                  {% endif %}
                  {% if back_user.has_permissions(BACKPermission.COMMENTER) %}
                     <li class="comments-manage"><a href="{{ url_for('back.comments') }}">评论管理</a></li>
                  {% endif %}
                  {% if back_user.has_permissions(BACKPermission.BOARDER) %}
                     <li class="board-manage"><a href="{{ url_for('back.boards') }}">板块管理</a></li>
                  {% endif %}
                  {% if back_user.has_permissions(BACKPermission.FRONTUSER) %}
                     <li class="fuser-manage"><a href="{{ url_for('back.fusers') }}">前台用户管理</a></li>
                  {% endif %}
                  {% if back_user.has_permissions(BACKPermission.BACKUSER) %}
                     <li class="buser-manage"><a href="{{ url_for('back.busers') }}">后台用户管理</a></li>
                  {% endif %}
                  {% if back_user.is_developer %}
                      <li class="nav-group role-manage"><a href="{{ url_for('back.roles') }}">开发者管理</a></li>
                  {% endif %}
{#                <li class="role-manage"><a href="#">git</a></li>#}
{#                <li class="nav-group cmsuser-manage"><a href="#">个人介绍</a></li>#}
{#                <li class="cmsrole-manage"><a href="#">羽毛球</a></li>#}
            </ul>
          </div>
          <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
{#                定义自己的标题#}
            <h1>{% block page_title %}{% endblock %}</h1>
            <div class="main_content">
{#            定义自己页面的主要内容，注意div的位置#}
                {% block main_content %}{% endblock %}
           </div>
          </div>
      </div>
    </div>
</body>
</html>